import React from 'react';
import {HashRouter as Router,Route,Switch} from 'react-router-dom';

import {createStore,applyMiddleware,compose} from 'redux'
import thunk from 'redux-thunk'
import {Provider} from 'react-redux'
import reducer from './reducer'

import CheckLogin from "./component/checkLogin";
import Login from './container/login'
import Register from './container/register'
import CommonLayout from './layout/layout'
import './App.css'

const reduxDevtools=window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
const store=createStore(reducer,compose(
  applyMiddleware(thunk),
  reduxDevtools?reduxDevtools:f=>f
))

function App() {
  return (
    <Provider store={store}>
      <div>
        <Router>
          <CheckLogin></CheckLogin>
          <Switch>
            <Route exact path='/login' component={Login}/>
            <Route exact path='/register' component={Register}/>
            <CommonLayout />
          </Switch>
        </Router>
      </div>
    </Provider>
  );
}

export default App;
